<?php

/**
 * Maikuro CMS
 *
 * LICENSE:
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * The license is bundled with this package in the file LICENSE.txt.
 * You may also obtain a copy of the License at this URL:
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @copyright  Copyright (c) 2010, Jonathan Hedrén
 * @author     Jonathan Hedrén <jonathan.hedren@gmail.com>
 * @license    http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
 */

    $baseUrl = $request->getApplicationPath();

?>

<h1><?php echo $title ?></h1>
<?php if ($hasCreatePermission): ?>
<form action="<?php echo $baseUrl; ?>/administrators/create/" method="get">
    <div class="create-action">
        <button type="submit"><span><?php echo Translator::translate('Create new administrator'); ?></span></button>
    </div>
</form>
<?php endif; ?>
<div class="container table-container">
    <?php if (count($administrators)): ?>
    <table>
        <tr>
            <th scope="col"><?php echo Translator::translate('Username'); ?></th>
            <th scope="col"><?php echo Translator::translate('Email'); ?></th>
            <?php if ($hasDeletePermission): ?>
            <th scope="col" class="actions"><?php echo Translator::translate('Actions'); ?></th>
            <?php endif; ?>
        </tr>
        <?php
        $i = 0;
        foreach ($administrators as $administrator): ?>
        <tr class="<?php echo ($i++ %2) ? 'even' : 'odd'; ?>">
            <td>
                <?php if ($hasEditPermission): ?>
                <a href="<?php echo $baseUrl; ?>/administrators/edit/<?php echo $administrator->id; ?>/"><?php echo $administrator->username; ?></a>
                <?php else: ?>
                <?php echo $administrator->username; ?>
                <?php endif; ?>
            </td>
            <td>
                <?php echo $administrator->email; ?>
            </td>
            <?php if ($hasDeletePermission): ?>
            <td class="action delete">
                <a href="<?php echo $baseUrl; ?>/administrators/delete/<?php echo $administrator->id; ?>/"><?php echo Translator::translate('Delete'); ?></a>
            </td>
            <?php endif; ?>
        </tr>

        <?php endforeach; ?>
    </table>
    <?php endif; ?>
</div>